package userservice

import (
	"context"
	user "cwgoexample/kitex_gen/user"
	"github.com/cloudwego/kitex/client/callopt"
	"github.com/cloudwego/kitex/pkg/klog"
)

func AddUser(ctx context.Context, user *user.User, callOptions ...callopt.Option) (resp bool, err error) {
	resp, err = defaultClient.AddUser(ctx, user, callOptions...)
	if err != nil {
		klog.CtxErrorf(ctx, "AddUser call failed,err =%+v", err)
		return nil, err
	}
	return resp, nil
}

func DeleteUser(ctx context.Context, id int64, callOptions ...callopt.Option) (resp bool, err error) {
	resp, err = defaultClient.DeleteUser(ctx, id, callOptions...)
	if err != nil {
		klog.CtxErrorf(ctx, "DeleteUser call failed,err =%+v", err)
		return nil, err
	}
	return resp, nil
}

func EditUser(ctx context.Context, user *user.User, callOptions ...callopt.Option) (resp bool, err error) {
	resp, err = defaultClient.EditUser(ctx, user, callOptions...)
	if err != nil {
		klog.CtxErrorf(ctx, "EditUser call failed,err =%+v", err)
		return nil, err
	}
	return resp, nil
}

func GetUserInfo(ctx context.Context, user *user.User, callOptions ...callopt.Option) (resp *user.User, err error) {
	resp, err = defaultClient.GetUserInfo(ctx, user, callOptions...)
	if err != nil {
		klog.CtxErrorf(ctx, "GetUserInfo call failed,err =%+v", err)
		return nil, err
	}
	return resp, nil
}

func GetUserList(ctx context.Context, offset int64, limit int64, callOptions ...callopt.Option) (resp []*user.User, err error) {
	resp, err = defaultClient.GetUserList(ctx, offset, limit, callOptions...)
	if err != nil {
		klog.CtxErrorf(ctx, "GetUserList call failed,err =%+v", err)
		return nil, err
	}
	return resp, nil
}
